<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="../templates/ui.xhtml">

    <ui:define name="content">
        <h1 class="title ui-widget-header ui-corner-all">Data Exporter</h1>
        <div class="entry">

            <h:form id="form">
                <p:dataTable id="tbl" var="car" value="#{tableBean.cars}" 
                             paginator="true" rows="10">
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Model" />
                        </f:facet>
                        <h:outputText value="#{car.model}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Year"/>
                        </f:facet>
                        <h:outputText value="#{car.year}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Manufacturer" />
                        </f:facet>
                        <h:outputText value="#{car.manufacturer}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Color" />
                        </f:facet>
                        <h:outputText value="#{car.color}" />
                    </p:column>

                </p:dataTable>

                <br />

                <h:panelGrid columns="2">
                    <p:panel header="Export All Data">
                        <h:commandLink id="excel">
                            <p:graphicImage value="/images/excel.png" />
                            <p:dataExporter type="xls" target="tbl" fileName="cars" />
                        </h:commandLink>

                        <h:commandLink id="pdf">
                            <p:graphicImage value="/images/pdf.png" />
                            <p:dataExporter type="pdf" target="tbl" fileName="cars"/>
                        </h:commandLink>

                        <h:commandLink id="csv">
                            <p:graphicImage value="/images/csv.png" />
                            <p:dataExporter type="csv" target="tbl" fileName="cars" />
                        </h:commandLink>

                        <h:commandLink id="xml">
                            <p:graphicImage value="/images/xml.png" />
                            <p:dataExporter type="xml" target="tbl" fileName="cars" />
                        </h:commandLink>
                    </p:panel>

                    <p:panel header="Export Page Data">
                        <h:commandLink>
                            <p:graphicImage value="/images/excel.png" />
                            <p:dataExporter type="xls" target="tbl" fileName="cars" pageOnly="true"/>
                        </h:commandLink>

                        <h:commandLink>
                            <p:graphicImage value="/images/pdf.png" />
                            <p:dataExporter type="pdf" target="tbl" fileName="cars" pageOnly="true"/>
                        </h:commandLink>

                        <h:commandLink>
                            <p:graphicImage value="/images/csv.png" />
                            <p:dataExporter type="csv" target="tbl" fileName="cars" pageOnly="true"/>
                        </h:commandLink>

                        <h:commandLink>
                            <p:graphicImage value="/images/xml.png" />
                            <p:dataExporter type="xml" target="tbl" fileName="cars" pageOnly="true"/>
                        </h:commandLink>
                    </p:panel>
                </h:panelGrid>

            </h:form>

            <h3>Source</h3>
            <p:tabView>
                <p:tab title="exporter.xhtml">
                    <pre name="code" class="xml">
&lt;p:dataTable id="tbl" var="car" value="\#{tableBean.cars}" paginator="true" rows="10"&gt;
	&lt;p:column&gt;
		&lt;f:facet name="header"&gt;
			&lt;h:outputText value="Model" /&gt;
		&lt;/f:facet&gt;
		&lt;h:outputText value="\#{car.model}" /&gt;
	&lt;/p:column&gt;

	&lt;p:column&gt;
		&lt;f:facet name="header"&gt;
			&lt;h:outputText value="Year" /&gt;
		&lt;/f:facet&gt;
		&lt;h:outputText value="\#{car.year}"/&gt;
	&lt;/p:column&gt;

	&lt;p:column&gt;
		&lt;f:facet name="header"&gt;
			&lt;h:outputText value="Manufacturer" /&gt;
		&lt;/f:facet&gt;
		&lt;h:outputText value="\#{car.manufacturer}" /&gt;
	&lt;/p:column&gt;

	&lt;p:column&gt;
		&lt;f:facet name="header"&gt;
			&lt;h:outputText value="Color" /&gt;
		&lt;/f:facet&gt;
		&lt;h:outputText value="\#{car.color}" /&gt;
	&lt;/p:column&gt;
&lt;/p:dataTable&gt;
	
&lt;h:panelGrid columns="2"&gt;
	&lt;p:panel header="Export All Data"&gt;
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/excel.png" /&gt;
			&lt;p:dataExporter type="xls" target="tbl" fileName="cars" /&gt;
		&lt;/h:commandLink&gt;

		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/pdf.png" /&gt;
			&lt;p:dataExporter type="pdf" target="tbl" fileName="cars"/&gt;
		&lt;/h:commandLink&gt;
		
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/csv.png" /&gt;
			&lt;p:dataExporter type="csv" target="tbl" fileName="cars" /&gt;
		&lt;/h:commandLink&gt;
		
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/xml.png" /&gt;
			&lt;p:dataExporter type="xml" target="tbl" fileName="cars" /&gt;
		&lt;/h:commandLink&gt;
	&lt;/p:panel&gt;
	
	&lt;p:panel header="Export Page Data"&gt;
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/excel.png" /&gt;
			&lt;p:dataExporter type="xls" target="tbl" fileName="cars" pageOnly="true"/&gt;
		&lt;/h:commandLink&gt;

		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/pdf.png" /&gt;
			&lt;p:dataExporter type="pdf" target="tbl" fileName="cars" pageOnly="true"/&gt;
		&lt;/h:commandLink&gt;
		
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/csv.png" /&gt;
			&lt;p:dataExporter type="csv" target="tbl" fileName="cars" pageOnly="true"/&gt;
		&lt;/h:commandLink&gt;
		
		&lt;h:commandLink&gt;
			&lt;p:graphicImage value="/images/xml.png" /&gt;
			&lt;p:dataExporter type="xml" target="tbl" fileName="cars" pageOnly="true"/&gt;
		&lt;/h:commandLink&gt;
	&lt;/p:panel&gt;
&lt;/h:panelGrid&gt;
                    </pre>
                </p:tab>
            </p:tabView>

        </div>

    </ui:define>
</ui:composition>
